package com.wzy.level.user.userServlet;

import com.wzy.Jdbc封装.pojo.News_detail;
import com.wzy.Jdbc封装.pojo.News_user;
import com.wzy.level.user.userService.userService;
import com.wzy.level.user.userServiceImpl.userServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/user")
public class user extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        userService user = new userServiceImpl();
        List<News_user> news_users1 = user.selectAll();
        int total = news_users1.size();
        HttpSession session = req.getSession();
        int count = (int) session.getAttribute("count");

        session.setAttribute("total",total);
        int totalPage =0;//总页数
        try {
            totalPage = (int)total/count;
        }catch (Exception e){
            e.printStackTrace();
        }
        session.setAttribute("totalPage",totalPage);

//        List<News_user> news_users = (List<News_user>) session.getAttribute("news_user_byPage");
//        session.setAttribute("news_users",news_users);
        resp.sendRedirect(req.getContextPath()+"/system/user.jsp");
    }
}
